package com.hxh.learn.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Collection;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import static com.hxh.common.constant.HxhConstant.*;

/**
 * <p>
 * 用户
 * </p>
 *
 * @author hxh
 * @since 2023-03-02
 */
@Data
@TableName("sys_user")
@ApiModel(value = "SysUser对象", description = "用户")
public class SysUser implements Serializable, UserDetails{

    private static final long serialVersionUID = 1L;
    @TableId(type= IdType.ASSIGN_ID)
    @ApiModelProperty("用户id")
    private String userId;

    @ApiModelProperty("姓名")
    private String userName;

    @ApiModelProperty("用户昵称")
    private String userNick;

    @ApiModelProperty("状态：0停用，1启用")
    private Integer userStatus;

    @ApiModelProperty("手机号")
    private String userPhone;

    @ApiModelProperty("用户头像url")
    private String userAvatar;

    @ApiModelProperty("密码")
    private String userPossword;

    @ApiModelProperty("创建时间")
    private Long createTime;

    @ApiModelProperty("创建人")
    private String createUser;

    @ApiModelProperty("修改时间")
    private Long updateTime;

    @ApiModelProperty("修改人")
    private String updateUser;

    @ApiModelProperty("登录时间")
    private Long loginTime;



    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return null;
    }

    @Override
    public String getUsername() {
        return null;
    }

    @Override
    public boolean isAccountNonExpired() {
        return false;
    }

    @Override
    public boolean isAccountNonLocked() {
        return false;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return false;
    }

    @Override
    public boolean isEnabled() {
        if (USER_STATUS_NO.equals(userStatus)){
            return false;
        }
        return true;
    }
}
